home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////
- // Pocket PC Game Programming
- // Chapter 10: Sound Effects and Music
- //
- // CWaveDevice Source File
- //
- // This file includes the CWaveDevice implementation.
- //
- ////////////////////////////////////////////////////////////
-
- #include "stdafx.h"
- #include "CWaveDevice.h"
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice Constructor
- //
- // This function is called when the class is instantiated.
- //
- CWaveDevice::CWaveDevice()
- {
- caps = new WAVEOUTCAPS;
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice Destructor
- //
- // This function is called when the class is terminated.
- //
- CWaveDevice::~CWaveDevice()
- {
- delete caps;
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice::DeviceFound
- //
- // Determines if sound hardware is available.
- //
- BOOL CWaveDevice::DeviceFound()
- {
- return (BOOL)(waveOutGetNumDevs() > 0);
-
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice::SupportsPlayback
- //
- // Determines whether minimum wave playback is supported.
- //
- BOOL CWaveDevice::SupportsPlayback()
- {
- BOOL bRet;
-
- res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
- if (res != MMSYSERR_NOERROR)
- {
- return FALSE;
- }
-
- if (caps->dwFormats & WAVE_FORMAT_1M08)
- bRet = TRUE;
- else
- bRet = FALSE;
-
- return bRet;
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice::SupportsStereo
- //
- // Determines whether stereo output is supported.
- //
- BOOL CWaveDevice::SupportsStereo()
- {
- BOOL bRet;
-
- res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
- if (res != MMSYSERR_NOERROR)
- {
- return FALSE;
- }
-
- if (caps->wChannels == 2)
- bRet = TRUE;
- else
- bRet = FALSE;
-
- return bRet;
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice::GetDriverVersion
- //
- // Returns the driver version of the sound driver.
- //
- float CWaveDevice::GetDriverVersion()
- {
- byte major, minor;
- float fRet;
-
- res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
- if (res != MMSYSERR_NOERROR)
- {
- return 0;
- }
-
- major = caps->vDriverVersion & 0x0F;
- minor = caps->vDriverVersion & 0xFF;
- fRet = (float)(major + minor * 0.01);
- return fRet;
- }
-
- ////////////////////////////////////////////////////////////
- // CWaveDevice::GetDriverName
- //
- // Returns the sound driver name.
- //
- LPTSTR CWaveDevice::GetDriverName()
- {
- MMRESULT res;
-
- res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
- if (res != MMSYSERR_NOERROR)
- {
- return NULL;
- }
-
- return caps->szPname;
- }
-
-